var express = require('express');
var router = express.Router();
const { getParkings, addParking,
    amendState, deleteParkings,
    checkCanChangeModify,
    modifyParkings ,
    getmyorders} = require('../service/parkingsService')
//配置二级路径
// router.get('/', function(req, res, next) {
//   res.send('respond with a resource');
// });

//获取出租方列表信息  
router.get('/getParkings', async function (req, res, next) {
    const data = await getParkings(req.query);
    res.send(data);
 
});


//验证用户的信息可否修改checkCanChangeModify
router.post('/checkCanChangeModify', async function (req, res, next) {

    const data = await checkCanChangeModify(req.body);
    res.send(data)
})

//确认修改车位数据
router.post('/modifyParkings', async function (req, res, next) {

    const data = await modifyParkings(req.body);
    res.send(data)
})

//删除车位信息
router.post('/deleteParkings', async function (req, res, next) {
    const data = await deleteParkings(req.body);
    res.send(data);
});

//添加车位 冰
router.post('/addParking', async function (req, res, next) {
    const data = await addParking(req.body.parkings);
    res.send(data.data);
});

//修改上下架的state 冰
router.post('/amendState', async function (req, res, next) {
    const { val } = { ...req.body }
    await amendState(val);
});



module.exports = router;